import React, { useEffect, useState } from 'react';
import { getProList } from '@/api/pro';
import {Table} from 'antd'


interface IPro {
  banners: string[]
  brand: string
  category: string
  desc: string
  discount: number
  img1: string
  img2: string
  img3: string
  img4: string
  isrecommend: number
  issale: number
  isseckill: number
  originprice: number
  proid: string
  proname: string
  sales: number
  stock: number
}

const index = () => {

  const [proList,setProList] = useState()

  useEffect(()=>{
    getProList().then(res => {
      console.log(res.data.data);
      setProList(res.data.data)
    })
  }, [])

  const columns = [
    {
      title: '序号',
      render(t:IPro,r:IPro,i:number){
        return (<span> {i+1} </span>)
      }
    },{
      title: '商品名称',
      dataIndex: 'proname'
    }
  ]

  return (
    <div>
      <h3>商品列表</h3>
      <Table dataSource={proList} rowKey={'proid'} columns={columns} />
    </div>
  );
};

export default index;
